/**
 * Created by xiangyufang on 2016/10/10.
 */
;(function($,window,document,undefined){
    /***全局变量初始化 start***/
    //任务Id
    var $taskId = $('#JQ_track_id').val();
    //表格
    var $table = $('#JQ_table');
    //列表div
    var $point_list = $("#JQ_track_message");
    //地图div
    var $point_map = $("#JQ_track_gis");
    //导入导出div
    var $port_btn = $('#JQ_handle_btn');

    //发球照片
    var $begin_img = $("#JQ_begin_img");

    //收球照片
    var $end_img = $("#JQ_end_img");
    //跟踪点照片
    var $link_img =$('#JQ_link_img');

    //所有点的详情数据
    var $all_detail = $('#JQ_all_detail');
    /***全局变量初始化 end***/

    //页面刷新
    function  refresh(){
        window.location.reload();
    }
    var refresh_time = window.setInterval(refresh,120000);
    var createRefresh = function createRefresh(){
        refresh_time = window.setInterval(refresh,120000);
    };
    //清除页面刷新
    var clearRefresh = function clearRefresh(){
        window.clearInterval(refresh_time);
    };


    var pointNull; //导出跟踪点数据
    DyyBase.ajax(cleanPipeApi.url_clean_trackDetail_data(),{taskId:$taskId}, function(dataset){
        if(dataset.bool){
            //removePoint();
            //头部
            var topData = dataset.result.pigTask;
            if (topData){
                bindTopMeg(topData);
            }
            //发球点
            var beginData = dataset.result.fromPig;
            if(beginData){
                bindBeginBall(beginData);
            }else{
                bindBeginBall();
            }
            //发球点照片
            var beginImg = dataset.result.fromPigImgs;
            if(beginImg){
                var beginPathData = DyyBase.getImagePath(beginImg);
                $begin_img.loadSmallImage(beginPathData);
            }else{
                $begin_img.loadSmallImage([]);
            }

            //跟踪点
            var pointData = dataset.result.taskPoints;
            var isAdverse = dataset.result.pigTask.isAdverseCurrent;
            var passMile = dataset.result.maxPoint;
            if(pointData.length <= 0){
                pointNull = 'false';
                //toggleBallDetail('a');
            }else{
                pointNull = 'true';
                loadPoint(pointData,isAdverse,passMile);
            }
            var pointTableData = dataset.result.taskPoints;
            loadPointTable(pointTableData);

            //收球点
            var endData = dataset.result.toPig;
            if(endData){
                bindEndBall(endData);
            }else{
                bindEndBall([]);
            }
            //收球点照片
            var endImg = dataset.result.toPigImgs;
            if(endImg){
                var endPathData = DyyBase.getImagePath(endImg);
                $end_img.loadSmallImage(endPathData);
            }else{
                $end_img.loadSmallImage([]);
            }
        }
    },{async:false});

    //控制发球点收球点跟踪点详情展示
    function toggleBallDetail(type){
        if(type == 'a'){
            $all_detail.show();
            $('#JQ_null_div').hide();
            $("#JQ_begin_detail").show();
            $("#JQ_end_detail").hide();
            $("#JQ_point_detail").hide();
        }else if(type == 'b'){
            $all_detail.show();
            $('#JQ_null_div').hide();
            $("#JQ_begin_detail").hide();
            $("#JQ_end_detail").show();
            $("#JQ_point_detail").hide();
        }else if(type == 'c'){
            $all_detail.show();
            $('#JQ_null_div').hide();
            $("#JQ_point_detail").show();
            $("#JQ_begin_detail").hide();
            $("#JQ_end_detail").hide();
        }else{
            $all_detail.hide();
            $("#JQ_begin_detail").hide();
            $("#JQ_end_detail").hide();
            $("#JQ_point_detail").hide();
        }
    }

    //渲染头部数据
    function  bindTopMeg(data){
        $("#JQ_taskName").text(data.taskName);
        $("#JQ_linesName").text(data.lineName);
        $("#JQ_pigType").text(data.pagTypeName);
        if(data.staus == '2'){
            $port_btn.show();
        }else if(data.staus == '3'){
            $port_btn.hide();
        }else if(data.staus == '4'){
            $port_btn.hide();
        }else{
            $port_btn.hide();
        }
    }

    //渲染发球点数据
    function bindBeginBall(beginData){
        //详情框发球点
        var $begin_ball = $("#JQ_begin_ball");
        var $begin_mile = $("#JQ_begin_mile");
        var $begin_pile = $("#JQ_begin_pile");
        var $begin_pileMile = $("#JQ_begin_pileMile");
        var $begin_time = $("#JQ_begin_time");
        var $begin_man = $("#JQ_begin_man");
        var $begin_out = $("#JQ_begin_out");
        var $begin_in = $("#JQ_begin_in");
        var $begin_flow = $("#JQ_begin_flow");
        var $begin_bore = $("#JQ_begin_bore");
        var $begin_type = $("#JQ_begin_type");
        var $begin_tool = $("#JQ_begin_tool");
        var $begin_pressure = $("#JQ_begin_pressure");
        var $begin_full = $("#JQ_begin_full");
        var $begin_recordMan = $("#JQ_begin_recordMan");
        var $begin_remark = $("#JQ_begin_remark");

        if(beginData){
            //滚动框发球点
            var data = DyyBase.clearNull(beginData);
            var $scroll_begin_ball = $("#JQ_scroll_begin_ball");
            $scroll_begin_ball.text(beginData.pipeValName);
            $scroll_begin_ball.attr('data-id',beginData.gisId);
            if(beginData.sendBallsTime && beginData.sendBallsTime != '-'){
                $("#JQ_begin_point").addClass("linkActive");
                $("#JQ_scroll_begin_time").text(beginData.sendBallsTime);
                toggleBallDetail('a');
            }else{
                toggleBallDetail();
            }
            if(beginData.arriveUser &&　beginData.arriveUser　!= '-'){

                $("#JQ_begin_point").find('div.xyf-begin-point-light').show();
            }
            $("#JQ_scroll_begin_mile").text(beginData.mileage);

            $begin_ball.text(data.pipeValName);
            $begin_mile.text(data.mileage);
            $begin_pile.text(data.reference);
            $begin_pileMile.text(data.referencedistance);
            $begin_time.text(data.sendBallsTime);
            $begin_man.text(data.arriveUser);
            $begin_out.text(data.ballsPressureFrom);
            $begin_in.text(data.ballsPressureTo);
            $begin_flow.text(data.ballsFlow);
            $begin_bore.text(data.interDiameter);
            $begin_type.text(data.pagType);
            $begin_tool.text(data.pagTool);
            $begin_pressure.text(data.pressure);
            $begin_full.text(data.interference);
            $begin_recordMan.text(data.recrder);
            $begin_remark.val(data.remark);
            //详情框的title
            $begin_ball.attr('title',data.pipeValName);
            $begin_mile.attr('title',data.mileage);
            $begin_pile.attr('title',data.reference);
            $begin_pileMile.attr('title',data.referencedistance);
            $begin_time.attr('title',data.sendBallsTime);
            $begin_man.attr('title',data.arriveUser);
            $begin_out.attr('title',data.ballsPressureFrom);
            $begin_in.attr('title',data.ballsPressureTo);
            $begin_flow.attr('title',data.ballsFlow);
            $begin_bore.attr('title',data.interDiameter);
            $begin_type.attr('title',data.pagType);
            $begin_tool.attr('title',data.pagTool);
            $begin_pressure.attr('title',data.pressure);
            $begin_full.attr('title',data.interference);
            $begin_recordMan.attr('title',data.recrder);
            $begin_remark.attr('title',data.remark);
        }else{
            $begin_ball.text('-');
            $begin_mile.text('-');
            $begin_pile.text('-');
            $begin_pileMile.text('-');
            $begin_time.text('-');
            $begin_man.text('-');
            $begin_out.text('-');
            $begin_in.text('-');
            $begin_flow.text('-');
            $begin_bore.text('-');
            $begin_type.text('-');
            $begin_tool.text('-');
            $begin_pressure.text('-');
            $begin_full.text('-');
            $begin_recordMan.text('-');
            $begin_remark.val('-');
            //详情框的title
            $begin_ball.attr('title','-');
            $begin_mile.attr('title','-');
            $begin_pile.attr('title','-');
            $begin_pileMile.attr('title','-');
            $begin_time.attr('title','-');
            $begin_man.attr('title','-');
            $begin_out.attr('title','-');
            $begin_in.attr('title','-');
            $begin_flow.attr('title','-');
            $begin_bore.attr('title','-');
            $begin_type.attr('title','-');
            $begin_tool.attr('title','-');
            $begin_pressure.attr('title','-');
            $begin_full.attr('title','-');
            $begin_recordMan.attr('title','-');
            $begin_remark.attr('title','-');

        }
    }
    //点击发球点
    $("#JQ_begin_point").click(function(){
        var isMap = $("#JQ_is_Map").text();
        if(isMap == '0'){
            if($(this).hasClass('linkActive')) {
                toggleBallDetail('a');
            }
        }else if(isMap == '1'){
            var $gisId = $("#JQ_scroll_begin_ball").attr('data-id');
            document.getElementById("dyMap").contentWindow.locateTarget($gisId,'piggingstructure');
        }
    });


    //渲染收球点数据
    function bindEndBall(endData){
        //收球点滚动框
        var $scroll_end_ball = $("#JQ_scroll_end_ball");
        $scroll_end_ball.text(endData.pipeValName);
        $scroll_end_ball.attr('data-id',endData.gisId);
        if(endData.arriveUser){
            $("#JQ_end_point").find('div.xyf-begin-point-light').show();
        }
        if(endData.backBallsTime){
            clearRefresh();
            toggleBallDetail('b');
            var endNullData = DyyBase.clearNull(endData);
            $("#JQ_end_point").addClass("linkActive");
            $("#JQ_scroll_end_time").text(endData.backBallsTime);
            var finishTip = '完成时间' + endNullData.backBallsTime +'，污水' +endNullData.sewage + '，污物'+ endNullData.dirt;
            $table.MSG({
                type: 'success',
                title: '任务已完成',
                content: finishTip,
                yesBtnTxt: '确认',
                //closeBtnAct: clearRefresh(),
                yesBtnAct: function(){
                    DyyBase.ajax(cleanPipeApi.url_clean_trackDetail_finish(),{taskId:$taskId},function(dataset){
                        if(dataset.bool){
                            window.location.href = cleanPipeApi.url_history_toHistory();
                        }
                    });
                }
            });
        }

        $("#JQ_scroll_end_mile").text(endData.mileage);
        var data = DyyBase.clearNull(endData);
        //收球点详情框
        var $end_ball = $("#JQ_end_ball");
        var $end_mile = $("#JQ_end_mile");
        var $end_pile = $("#JQ_end_pile");
        var $end_pileMile = $("#JQ_end_pileMile");
        var $end_time = $("#JQ_end_time");
        var $end_man = $("#JQ_end_man");
        var $end_out = $("#JQ_end_out");
        var $end_in = $("#JQ_end_in");
        var $end_flow = $("#JQ_end_flow");
        var $end_pressure = $("#JQ_end_pressure");
        var $end_speed = $("#JQ_end_speed");
        var $end_water = $("#JQ_end_water");
        var $end_goods = $("#JQ_end_goods");
        var $end_air = $("#JQ_end_air");
        var $end_pipeAir = $("#JQ_end_pipeAir");
        var $end_gas = $("#JQ_end_gas");
        var $end_temper = $("#JQ_end_temper");
        var $end_runMile = $("#JQ_end_runMile");
        var $end_coe = $("#JQ_end_coe");
        var $end_recordMan = $("#JQ_end_recordMan");
        var $end_cleanTime = $("#JQ_end_cleanTime");
        var $end_ratio = $("#JQ_end_ratio");
        var $end_pull = $("#JQ_end_pull");
        var $end_toolDetail = $("#JQ_end_toolDetail");
        var $end_remark = $("#JQ_end_remark");

        $end_ball.text(data.pipeValName);
        $end_mile.text(data.mileage);
        $end_pile.text(data.reference);
        $end_pileMile.text(data.referencedistance);
        $end_time.text(data.backBallsTime);
        $end_man.text(data.arriveUser);
        $end_out.text(data.ballsPressureFrom);
        $end_in.text(data.ballsPressureTo);
        $end_flow.text(data.ballsFlow);
        $end_pressure.text(data.maxPushPressure);
        $end_speed.text(data.avgRate);
        $end_water.text(data.sewage);
        $end_goods.text(data.dirt);
        $end_air.text(data.ventGasVolume);
        $end_pipeAir.text(data.actualPassGasVolume);
        $end_gas.text(data.gasRelativedEnsity);
        $end_temper.text(data.avgTempreture);
        $end_runMile.text(data.pigRunLength);
        $end_coe.text(data.compressionCoefficient);
        $end_recordMan.text(data.recrder);
        $end_cleanTime.text(data.pagDate);
        $end_ratio.text(data.avgSpeed);
        $end_pull.text(data.interference);
        $end_toolDetail.text(data.pigDescribe);
        $end_remark.text(data.dirtdescRiption);

        $end_ball.attr('title',data.pipeValName);
        $end_mile.attr('title',data.mileage);
        $end_pile.attr('title',data.reference);
        $end_pileMile.attr('title',data.referencedistance);
        $end_time.attr('title',data.backBallsTime);
        $end_man.attr('title',data.arriveUser);
        $end_out.attr('title',data.ballsPressureFrom);
        $end_in.attr('title',data.ballsPressureTo);
        $end_flow.attr('title',data.ballsFlow);
        $end_pressure.attr('title',data.maxPushPressure);
        $end_speed.attr('title',data.avgRate);
        $end_water.attr('title',data.sewage);
        $end_goods.attr('title',data.dirt);
        $end_air.attr('title',data.ventGasVolume);
        $end_pipeAir.attr('title',data.actualPassGasVolume);
        $end_gas.attr('title',data.gasRelativedEnsity);
        $end_temper.attr('title',data.avgTempreture);
        $end_runMile.attr('title',data.pigRunLength);
        $end_coe.attr('title',data.compressionCoefficient);
        $end_recordMan.attr('title',data.recrder);
        $end_cleanTime.attr('title',data.pagDate);
        $end_ratio.attr('title',data.avgSpeed);
        $end_pull.attr('title',data.interference);
        $end_toolDetail.attr('title',data.pigDescribe);
        $end_remark.attr('title',data.dirtdescRiption);
    }
    //点击收球点触发函数
    $("#JQ_end_point").click(function(){
        var isMap = $("#JQ_is_Map").text();
        if(isMap == '0'){
            if($(this).hasClass('linkActive')) {
                toggleBallDetail('b')
            }
        }else if(isMap == '1'){
            var $gisId = $("#JQ_scroll_end_ball").attr('data-id');
            document.getElementById("dyMap").contentWindow.locateTarget($gisId,'piggingstructure');
        }
    });

    //渲染滚动框跟踪点
    function loadPoint(data,type,max){
        if(data){
            var $begin_point = $("#JQ_link_point");
            var $slide = $("#JQ_xyf_slide");
            var visibleData = data;
            var len = visibleData.length;
            if(len>0){
                var slide_w = 220*len + 160*2;
                $("#JQ_slide_content").css("width",slide_w);
                var curId; //当前跑到跟踪点的Id
                for(var i=0;i<len;i++){
                    var content,sort_left;
                    //判断跟踪点是否通过
                    if(max){
                        var mile = max.mileage;
                        if(visibleData[i].mileage == mile){
                            curId = visibleData[i].id;
                        }
                        if(type == '0'){
                            if(visibleData[i].mileage <= mile){
                                content = '<div id="' + visibleData[i].id + '" data-id="' + visibleData[i].gisId + '"  class="xyf-link-point linkActive">';
                                sort_left = 220*i + 180;
                                $slide.scrollLeft(sort_left);
                            }else{
                                content = '<div id="' + visibleData[i].id + '" data-id="' + visibleData[i].gisId + '"  class="xyf-link-point">';
                            }
                        }else if(type == '1'){
                            if(visibleData[i].mileage >= mile){
                                content = '<div id="' + visibleData[i].id + '" data-id="' + visibleData[i].gisId + '"  class="xyf-link-point linkActive">';
                                sort_left = 220*i + 180;
                                $slide.scrollLeft(sort_left);
                            }else{
                                content = '<div id="' + visibleData[i].id + '" data-id="' + visibleData[i].gisId + '"  class="xyf-link-point">';
                            }
                        }
                    }else{
                        content = '<div id="' + visibleData[i].id + '" data-id="' + visibleData[i].gisId + '"  class="xyf-link-point">';
                    }
                    //判断跟踪点是否有人
                    if(visibleData[i].arriveUser){
                        content += '<div class="xyf-link-point-light"></div>';
                    }
                    content += '<div class="xyf-link_point-top"><div class="link_point-top-img"></div><div class="link_point-top-line"></div><div class="clear"></div></div>';
                    content += '<p class="link-point-number">'+ visibleData[i].locationDescription + '</p>';
                    content += '<p>绝对距离(m)：' + visibleData[i].mileage + '</p>';
                    if(visibleData[i].passTime){
                        content += '<p>' + visibleData[i].passTime + '</p>';
                    }
                    if(visibleData[i].avgSpeed){
                        content += '<p>平均速度：' + visibleData[i].avgSpeed + 'm/s</p>';
                    }
                    content +='</div>';
                    var $link_point = $(content);
                    $begin_point.append($link_point);
                }
                //显示最近通过的跟踪点详情
                if(curId){
                    clickPoint(curId);
                }

            }
        }
    }
    //点击跟踪点
    $("#JQ_slide_content").delegate("div.xyf-link-point",'click',function(){
        var isMap = $("#JQ_is_Map").text();
        var $this = $(this);
        if(isMap == '0'){
            if($this.hasClass('linkActive')){
                var Id = $this.attr("id");
                clickPoint(Id);
            }
        }else if(isMap == '1'){
            var $gisId = $this.attr("data-id");
            document.getElementById("dyMap").contentWindow.locateTarget($gisId,'mark');
        }
    });

    function clickPoint(id){
        toggleBallDetail('c');
        DyyBase.ajax(cleanPipeApi.url_clean_trackDetail_point(),{pointId:id}, function(dataset){
            if(dataset.bool){
                var pointDetailData = dataset.result.taskPoint;
                if(pointDetailData){
                    loadPointDetail(pointDetailData);
                }
                var pointImgData = dataset.result.pointImgs;
                var pointPathData = DyyBase.getImagePath(pointImgData);
                $link_img.loadSmallImage(pointPathData,clearRefresh,createRefresh);
            }
        });
    }
    //绑定到跟踪点详情
    function loadPointDetail(pointData){
        var data = DyyBase.clearNull(pointData);
        var $point_track = $("#JQ_point_track");
        var $point_mile = $("#JQ_point_mile");
        var $point_near = $("#JQ_point_near");
        var $point_nearMile = $("#JQ_point_nearMile");
        var $point_time = $("#JQ_point_time");
        var $point_man = $("#JQ_point_man");
        var $point_remark = $("#JQ_point_remark");

        $point_track.text(data.locationDescription);
        $point_mile.text(data.mileage);
        $point_near.text(data.reference);
        $point_nearMile.text(data.referenceDistance);
        $point_time.text(data.passTime);
        $point_man.text(data.recrder);
        $point_remark.text(data.createRemark);

        $point_track.attr('title',data.locationDescription);
        $point_mile.attr('title',data.mileage);
        $point_near.attr('title',data.reference);
        $point_nearMile.attr('title',data.referenceDistance);
        $point_time.attr('title',data.passTime);
        $point_man.attr('title',data.recrder);
        $point_remark.attr('title',data.createRemark);
    }

    //绑定跟踪点表格数据
    function loadPointTable(data){
        var pointTableData = DyyBase.clearNull(data);
        $table.DataTable({
            'language': {
                'zeroRecords': DyyBase.table_empty()
            },
            'info': false,
            'paging': false,
            'scrollY': 343,
            'autoWidth': false,
            'order': [],
            'serverSide': false,
            'pageLength': 1000,
            'ordering': false,
            'processing': false,
            'searching': false,
            'lengthChange': false,
            'data': pointTableData,
            'columns': [
                {
                    data: 'dataNum',
                    render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                },
                {
                    data: 'locationDescription',
                    render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                },
                {
                    data: 'mileage',
                    render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                },
                {
                    data: 'reference',
                    render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                },
                {
                    data: 'referenceDistance',
                    render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                },
                {
                    data: 'passTime',
                    render: function (data) {
                        return '<span title="' + data + '">' + Dyy.getDate(data) + '</span>';
                    }
                },
                {
                    data: 'recrder',
                    render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                },
                {
                    data: 'createRemark',
                    render: function (data) {
                        return '<span title="' + data + '">' + data + '</span>';
                    }
                },
                {
                    data: 'id',
                    render: function (data) {
                        return '<i data-a="' + data + '" class="xyf-see-image-icon" title="查看图片"></i>';
                    }
                }
            ]
        });
        var $scrollBody = $('div.dataTables_scrollBody');
        $scrollBody.css('overflow-x','hidden');
        var $scrollHeadInner = $('div.dataTables_scrollHeadInner');
        if(pointTableData.length>9){
            var scroll_w = $("h3").width();
            $scrollHeadInner.css('width',scroll_w-17);
            $scrollHeadInner.find('table').css('width',scroll_w-17);
        }else if(pointTableData.length>0 && pointTableData.length<=9){
            $scrollHeadInner.css('width','100%');
            $scrollHeadInner.find('table').css('width','100%');
            $scrollBody.css('height',pointTableData.length*39);
            //$scrollBody.css('borderRight','1px solid #e2e2e2');
        }else{
            $scrollHeadInner.css('width','100%');
            $scrollHeadInner.find('table').css('width','100%');
            $scrollBody.empty();
            var $dataEmpty = $('<div class="xyf-datatable-empty"></div>');
            $scrollBody.append($dataEmpty);
        }
    }


    //查看图片
    $table.on("click","i.xyf-see-image-icon",function(){
        clearRefresh();
        var $this = $(this);
        var id = $this.attr('data-a');
        DyyBase.ajax(cleanPipeApi.url_clean_trackDetail_img(),{businessId:id}, function(dataset){
            if(dataset.bool){
                if(dataset.result.length >0){
                    var data = dataset.result;
                    var pathData = DyyBase.getImagePath(data);
                    console.log(pathData);
                    $('#JQ_img_div').loadImg(pathData,'',createRefresh);
                }else{
                    $this.MSG({'content':'该跟踪点没有上传图片！','yesBtnAct':createRefresh,'closeBtnAct': createRefresh});
                }
            }
        });
    });

    //导入跟踪点记录
    $("#JQ_import_btn").click(function(){
        clearRefresh();
        var upPath = "/pig/cleanPipeLineTrack/importTrackPoint.json?taskId="+$taskId;
        var title = "导入跟踪点数据";
        var data_={"upUrl":upPath,"title":title};
        openUploadDialog(data_);
    });
    
    //导出
    $('#JQ_export_btn').click(function(){
        if(pointNull == 'true'){
            var taskName = $("#JQ_taskName").text();
            var lineName = $("#JQ_linesName").text();
            $(this).EXPT({
                type: 'name',
                name: lineName + taskName + '跟踪点信息表',
                param: {taskId:$taskId},
                server: DyyBase.root_path + '/pig/cleanPipeLineTrack/exportTrackPoint.json'
            });
        }else{
            $(this).MSG({content:'没有跟踪点数据，不能进行导出操作！'});
        }
    });

    //切换到列表页
    var $list = $("#JQ_toggle_list");
    var $map = $("#JQ_toggle_map");
    $list.click(function(){
        toggleLM('list');
        window.sessionStorage.pigTrack = 'list';
    });

    //切换到地图部分，加载GIS地图和跟踪点
    $map.click(function(){
        toggleLM('map');
        loadGIS();
        window.sessionStorage.pigTrack = 'map';
    });

    function toggleLM(type){
        var $top = $("#JQ_track_top"); //顶部模块
        var $isMap = $("#JQ_is_Map");  //是否在地图模块
        if(type == 'list'){
            $list.addClass('active');
            $map.removeClass("active");
            $point_list.show();
            $point_map.hide();
            $top.show();
            $isMap.text("0");
        }else if(type == 'map'){
            $map.addClass('active');
            $list.removeClass("active");
            $point_list.hide();
            $point_map.show();
            $top.hide();
            $isMap.text("1");
        }
    }

    if(window.sessionStorage.pigTrack == 'list'){
        toggleLM('list');
    }else if(window.sessionStorage.pigTrack == 'map'){
        toggleLM('map');
        loadGIS();
    }else{
        toggleLM('list');
        window.sessionStorage.pigTrack = 'list';
    }

    //加载gis地图
    function loadGIS(){
        var gisResourcePath = $("#gisResourcePath").val();
        DyyBase.ajax(cleanPipeApi.url_clean_trackDetail_gis(), {taskId: $taskId}, function (dataset) {
            loadGis($("#mapDiv"), gisResourcePath + 'baseMapPigTaskTrack.jsp',dataset.result);
        });
    }

    //返回上一页
    $('#JQ_back').click(function(){
        window.location.href = cleanPipeApi.url_clean_back_track();
    });


})(jQuery,window,document);
